<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <textarea></textarea><button>发布</button>
    <ul>
    </ul>
</body>
</html>
<script>
    var ul=document.querySelector("ul")
    var but=document.querySelector("button")
    var text=document.querySelector("textarea")
    but.onclick=function(){
        var li=document.createElement("li")
        if(text.value.trim()==''){
            alert("不能为空")
            return
        }
        li.innerHTML=text.value;
        ul.appendChild(li)
        text.value=''
    }
</script>